home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-03-19 | 10.4 KB | 299 lines | [TEXT/MPS ] |
- #
- # ****************************************************************************
- #
- # File Name: TRACS.Lib
- #
- # Contains: Library used for logging TRACS data.
- #
- # Written by: JC
- #
- # Copyright: © 1993-1996 by Apple Computer, Inc., all rights reserved.
- #
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- #
- # Vers Date Author Description
- # ---- -------- ------ ---------------------------------------------
- # <6> 6/18/96 MDF Added support to TRACS_Output() task in order to track the
- # number of failed test cases.
- # <5> 3/11/96 JC Modified to call BuildSuiteFields regardless if Results Express
- # global to set to false if TRACS global is set to true.
- # <4> 2/29/96 JC Added carriage return after TRACS output checksum.
- # <3> 2/26/96 JC Minor fix variable name.
- # <2> 2/26/96 JC Added suite result code comments.
- # <1> 2/23/96 JC first checked in
- #
- # ****************************************************************************
- #
-
- ########################################################################
- # External libraries
- #=======================================================================
- Libraries 'ExceptionHandling.Lib', 'FileToolOperations.Lib';
-
- #########################################################################
- # TRACS_DataCollection()
- #========================================================================
- # Author: JC
- # Description: Collects TRACS output data and stores it in a global variable. It will
- # then call TRACS_Output() for formatting & writing when parameter pDataComplete
- # is equal to true.
- # Parameters: pData
- # Returns: Nothing
- # Examples: TRACS_DataCollection(pTRACS_Data, pDataComplete := 0)
- # Assumptions:
- #
- #########################################################################
- #========================================================================
- # History:
- #########################################################################
- task TRACS_DataCollection(pTRACS_Data, pDataComplete := 0)
- begin
-
- global gTRACS_OutputData := gTRACS_OutputData + pTRACS_Data;
-
- if (pDataComplete)
- TRACS_Output(gTRACS_OutputData);
-
- end;
- #########################################################################
- # TRACS_CreateOutputFile()
- #========================================================================
- # Author: JC
- # Description: Checks to see if TRACS output folder/s (pTRACSFileNamePath) exists
- # if not it will create them (using Filetool on the host).
- #
- # Parameters: pTRACSFileNamePath = folder/file path.
- # Returns:
- # Examples: TRACSFileNamePath := TRACS_CreateOutputFile(pTRACSFileNamePath);
- # Assumptions:
- #
- #########################################################################
- #========================================================================
- # History:
- #########################################################################
- task TRACS_CreateOutputFile(pTRACSFileNamePath)
- begin
-
- switch ExistsOrCreate(pTRACSFileNamePath, 0)
- begin
- case 1:
- println "## TRACS output folder existed: {pTRACSFileNamePath}";
- case 2:
- println "## Created TRACS output file: {pTRACSFileNamePath}";
- case 3:
- println "## Created TRACS output folder: {pTRACSFileNamePath}";
- default:
- println "## Fail ({pTRACSFileNamePath}, doesn't exist, couldn't create TRACS output folder)";
- end;
-
- end;
- #########################################################################
- # TRACS_CreateFilePath()
- #========================================================================
- # Author: JC
- # Description: Creates TRACS folder/file paths. First folder will be
- # named "TRACSOutput", second folder, within the first one will
- # be named the suite name. A output file is also generated using
- # the target name and date/time as the file name.
- #
- # Parameters: pSuiteName = suite name.
- # pTargetName = target name.
- # Returns: TRACS File Name/Path
- # Examples: TRACSFileNamePath := TRACS_CreateOutputFile(SuiteName, TargetName);
- # Assumptions:
- #
- #########################################################################
- #========================================================================
- # History:
- #########################################################################
- task TRACS_CreateFilePath(pSuiteName, pTargetName)
- begin
- HostBootVol := NameOfBootVolume(0);
-
- TRACSFileNamePath := "{HostBootVol}:TRACSOutput:";
-
- TRACS_CreateOutputFile(TRACSFileNamePath);
-
- TRACSFileNamePath := "{HostBootVol}:TRACSOutput:{pSuiteName}:";
-
- TRACS_CreateOutputFile(TRACSFileNamePath);
-
- Try
- begin
- match[time d:?day m:?month y:?year h:?hour s:?seconds];
- timestamp := "{month}{day}{hour}{seconds}";
- end;
- catch theError
- ExceptionDispatcher(theError);
-
- TRACSFileNamePath := "{HostBootVol}:TRACSOutput:{pSuiteName}:{pTargetName}{timestamp}";
-
- TRACS_CreateOutputFile(TRACSFileNamePath);
-
- return(TRACSFileNamePath);
- end;
- #########################################################################
- # TRACS_Output()
- #========================================================================
- # Author: JC
- # Description: This task will order the TRACS data correctly and call FileTool to
- # write to the file.
- # Parameters: pTRACS_OutputData = a list of TRACS data.
- # Returns: Nothing
- # Examples: TRACS_Output(gTRACS_OutputData);
- # Assumptions:
- #
- #########################################################################
- #========================================================================
- # History:
- #
- # 2/26/96 JC Added suite result code comments.
- # MDF 06/18/96 Added support for tracking number of failed test cases.
- #########################################################################
- task TRACS_Output(pTRACS_OutputData)
- begin
- println "";
-
- SuiteName := assoc("SuiteName", pTRACS_OutputData);
- TargetName := assoc("TargetName", pTRACS_OutputData);
-
- TRACSFileNamePath := TRACS_CreateFilePath(SuiteName, TargetName);
-
- Comment_Text := "";
- numTimes := Card(pTRACS_OutputData);
-
- for i := 1 to numTimes # For each element of the pTRACS_Data
- begin
- Comment_Text := Comment_Text + pTRACS_OutputData[i][1] + ":" + ToText(pTRACS_OutputData[i][2]) + " ";
- end;
-
- SuiteCompletionDate := assoc("Suite End Date", pTRACS_OutputData);
-
- SuiteResultCode := assoc("Suite Completion Code", pTRACS_OutputData);
-
- switch SuiteResultCode
- begin
- case -1: ## -1 (SPEC S&L) = Skipped
- SuiteResultCode := "5"; ## 5 (TRACS) = Not Executed
- case -2: ## -2 (SPEC S&L) = System Failure
- SuiteResultCode := "2"; ## 2 (TRACS) = Fail
- case -3: ## -3 (SPEC S&L) = Not Validated
- SuiteResultCode := "5"; ## 5 (TRACS) = Not Executed
- case 0: ## 0 (SPEC S&L) = Incomplete
- SuiteResultCode := "2"; ## 2 (TRACS) = Fail
- case 1: ## 1 (SPEC S&L) = OK
- SuiteResultCode := "1"; ## 1 (TRACS) = Pass
- default:
- SuiteResultCode := "7"; ## 7 (TRACS) = Invalid
- end;
-
- NotExecuted := assoc("TCS Not Avail", pTRACS_OutputData);
- SuiteTCSPassed := assoc("TCS Passed", pTRACS_OutputData);
- Failed := assoc("TCS Failed",pTRACS_OutputData);
- ExpFailure := assoc("TCS Exp Count", pTRACS_OutputData);
- Blocked := "0";
- Canceled := "0";
- Invalid := "0";
-
- unformattedData := {SuiteName,
- SuiteCompletionDate,
- SuiteResultCode,
- NumericVal,
- ErrorMsg,
- RadarNo,
- NotExecuted,
- SuiteTCSPassed,
- Failed,
- ExpFailure,
- Blocked,
- Canceled,
- Invalid,
- Comment_Text
- };
-
- formattedData := TRACSFormatData(unformattedData);
-
- WriteToFileToolHost(TRACSFileNamePath, formattedData );
-
- QuitFileTool(0);
- end;
-
- #########################################################################
- # ToText()
- #========================================================================
- # Author: JC
- # Description: a utility task to convert integer data to strings.
- # Parameters: pData
- # Returns: Nothing
- # Examples:
- # Assumptions:
- #
- #########################################################################
- #========================================================================
- # History:
- #########################################################################
- task ToText( pData )
- begin
- if( typeOf( pData ) = 'string' ) return pData;
- if( typeOf( pData ) = 'integer' ) return NumToStr( pData );
- return undefined; # else
- end;
- #########################################################################
- # WriteToFileToolHost()
- #========================================================================
- # Author: JC
- # Description: a utility task used by WriteToFile.
- # Parameters: pTRACSFileNamePath = file name path
- # pformattedData = formatted data (list)
- # Returns: Nothing
- # Examples:
- # Assumptions:
- #
- #########################################################################
- #========================================================================
- # History:
- #########################################################################
- task WriteToFileToolHost( pTRACSFileNamePath, pformattedData )
- begin
- FileToolReturnVal := _FileTool('Write', {pTRACSFileNamePath, 0, pformattedData},0);
- return FileToolReturnVal;
- end;
- #########################################################################
- # TRACSFormatData()
- #========================================================================
- # Author: JC
- # Description: This task will receive a list of ordered TRACS column data,
- # if the list element is undefined it will insert a blank tab in
- # its place so TRACS knows there is no data for that column.
- # Parameters: pUnformattedData = list of ordered TRACS column data.
- # Returns: formatted String
- # Examples: formattedData := TRACSFormatData(unformattedData);
- # Assumptions: list of ordered TRACS column data.
- #
- #########################################################################
- #========================================================================
- # History:
- # JC 2/29/96 Added ∂n (carriage return) after numOfRows variable.
- #########################################################################
- task TRACSFormatData(pUnformattedData := {})
- begin
- Tab := "∂t";
- formattedString := "";
- numOfRows := 1;
-
- numTimes := Card(pUnformattedData);
-
- for i := 1 to numTimes # For each element of the pTRACS_OutputData
- begin
- if (IsUndefined(pUnformattedData[i]))
- pUnformattedData[i] := "";
-
- formattedString := formattedString + ToText(pUnformattedData[i]) + Tab;
- end;
-
- formattedString := formattedString + "∂n{numOfRows}∂n";
-
- return(formattedString);
- end;